-- web config 
WIFI = 4
gpio.mode(WIFI, gpio.OUTPUT)
gpio.write(WIFI, gpio.LOW)
wifi.setmode(wifi.STATION)
local sta_config=wifi.sta.getconfig(true)
--if(sta_config)
--then
--    print("\tthis is wifi...")
--    print(string.format("\tCurrent wifi station config\n\tssid:\"%s\"\tpassword:\"%s\"", sta_config.ssid, sta_config.pwd))
--    station_cfg={}
--    station_cfg.ssid=sta_config.ssid
--    station_cfg.pwd=sta_config.pwd
----    station_cfg.auto=true
--    station_cfg.save=true
--    wifi.sta.config(station_cfg)
--    wifi.sta.connect()
--    print("turn off the light on board..")
--    gpio.write(WIFI, gpio.HIGH)
--    dofile("kaiguan.lua")
--else
--    print('\t no wifi ')
--    print('\t webconfig now ... ')
--startconfig()
--end

--function startconfig()
    wifi.startsmart(0,
    function(ssid, password)
    --    print("Connected to wifi as:" .. wifi.sta.getip())
        print("turn off the light on board..")
        gpio.write(WIFI, gpio.HIGH)
        do
        print(string.format("Success. SSID:%s ; PASSWORD:%s", ssid, password))
        station_cfg={}
        station_cfg.ssid=ssid
        station_cfg.pwd=password
        station_cfg.save=true
        wifi.sta.config(station_cfg)
        end
        dofile("kaiguan.lua")
        end
    )
--end

